import axios from '../utils/ServerLzx'
import api from '../api'

let purchasing = {
    Add_SalesOrder,
    Approval_PurOrder,
    Delete_PurOrder,
    Query_PurOrderList,
    Query_PurOrderListById,
    Update_PurOrder,
}
//增加订单
 function Add_SalesOrder(data) {

    return new Promise ((resolve,reject)=>{
        axios({
            url:api.Purchasing.Add_PurOrder,
            method: data.method,
            data:data.data
        })
        .then((res)=>{
          resolve(res)
        })
        .catch((err)=>{
            reject(err)
        })
    })
   
}

//审核订单

function Approval_PurOrder(data) {

    return new Promise ((resolve,reject)=>{
        axios({
            url:api.Purchasing.Approval_PurOrder,
            method: data.method,
            params:data.data   //为啥用params
        })
        .then((res)=>{
          resolve(res)
        })
        .catch((err)=>{
            reject(err)
        })
    })
   
}

//删除采购订单接口
function Delete_PurOrder(data) {

    return new Promise ((resolve,reject)=>{
        axios({
            url:api.Purchasing.Delete_PurOrder,
            method: data.method,
            params:data.data   //为啥用params
        })
        .then((res)=>{
          resolve(res)
        })
        .catch((err)=>{
            reject(err)
        })
    })
   
}
//分页查询

function Query_PurOrderList(data) {

    return new Promise ((resolve,reject)=>{
        axios({
            url:api.Purchasing.Query_PurOrderList,
            method: data.method,
            params:data.data   //为啥用params
        })
        .then((res)=>{
          resolve(res)
        })
        .catch((err)=>{
            reject(err)
        })
    })
   
}
//订单预览

function Query_PurOrderListById(data) {

    return new Promise ((resolve,reject)=>{
        axios({
            url:api.Purchasing.Query_PurOrderListById,
            method: data.method,
            params:data.data   //post为啥用params
        })
        .then((res)=>{
          resolve(res)
        })
        .catch((err)=>{
            reject(err)
        })
    })
   
}
//订单预览

function Update_PurOrder(data) {

    return new Promise ((resolve,reject)=>{
        axios({
            url:api.Purchasing.Update_PurOrder,
            method: data.method,
            data:data.data   
        })
        .then((res)=>{
          resolve(res)
        })
        .catch((err)=>{
            reject(err)
        })
    })
   
}



export default purchasing